<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/js/common.js"/>"></script>
<script>
	function initList(listDisplayEId) {
		$('#' + listDisplayEId)
				.datagrid(
						{
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							toolbar : [ {
								id : listDisplayEId + '_btn_add',
								text : '新增',
								iconCls : 'icon-add',
								handler : function() {
									window.open(
													"<c:url value='/jsp/openIndexSun.jsp?url=/companySup/preSaveCompanyForSup.do'/>",
													"sun",
													"width=1200px,height=600px,status=no,scrollbars=yes");
									$('#' + listDisplayEId).datagrid('reload');
								}
							} ],
							onLoadError : function() {
								$.messager.alert('错误', '获取数据失败，请与管理员联系！',
										'error');
							},
							onClickRow : function(rowIndex) {
								$(".myrad").prop("checked", false);
								$(".myrad").eq(rowIndex).prop("checked", true);
							}
						});
	};
	$(document).ready(function() {
		initList('listDisplay');
	});

	function formatRadio(value, rowData, rowIndex) {
		return value = "<input type='radio' class='myrad'  name='radioUser' />";
	}

	function searchInfo() {

		$('#listDisplay').datagrid('load', {
			userName : $('#userName').val(),
			realName : $('#realName').val(),
			roleName : $('#roleName').val()
		});
	}

	function goDetailedShop(val, rowData, rowIndex) {
		return '<a href="#" onclick="constructionManager(\''
				+ rowData.companyId + '\')">查看店面信息</a>  '
	}

	function constructionManager(id) {
		var new_win = window.open(
				"<c:url value='/jsp/openIndexSun.jsp?url=/companySup/goDetailedShopForSup.do'/>"
						+ "?companyId=" + id, "sun",
				"width=1200px,height=600px,status=no,scrollbars=yes");

		new_win.focus();
	}
	
	function goDetailedSup(val, rowData, rowIndex) {
        return '<a href="#" onclick="constructionManager1(\''
                + rowData.companyId + '\')">查看配送中心信息</a>  '
    }

    function constructionManager1(id) {
        var new_win = window.open(
                "<c:url value='/jsp/openIndexSun.jsp?url=/company/goDetailedSup.do'/>"
                        + "?companyId=" + id, "sun",
                "width=1200px,height=600px,status=no,scrollbars=yes");

        new_win.focus();
    }
    
    
    //订单状态格式
    function formatterShop(value, row, index, field) {
        if (value == "1") {
            return "有";
        } else {
        	return "无";
        }
    }
    //订单状态格式
    function formatterSup(value, row, index, field) {
    	if (value == "1") {
            return "有";
        } else {
            return "无";
        }
    }
</script>
</head>
<body>
	<table width="98%">
		<tr>
			<td>
				<div
					style="height: auto; width: 1180px; background: #fafafa; padding: 5px;"
					class="easyui-panel" title="用户 查询" iconCls="icon-search"
					collapsible="true" minimizable="false" maximizable="false"
					closable="false">
					<form id="searchForm" name="searchForm" method="post"
						action="userlist.txt"
						onsubmit="return searchDGData(this.id,'listDisplay');">
						<div>
							<table>
								<tr>
									<td>公司名：</td>
									<td><input type="text" id="companyName" name="companyName"></input>
									</td>
								</tr>
								<tr>
									<td><inputtype ="button" onclick="searchInfo()" value="查询"></td>
								</tr>
							</table>
						</div>
					</form>
				</div>
			</td>
		</tr>
		<tr style="height: 12px;"></tr>
		<tr>
			<td>
				<table id="listDisplay" title="公司列表" iconCls="icon-list"
					singleSelect="true" idField="id"
					url="<c:url value="/companySup/companyListForSup.do"/>" loadMsg="请稍候......"
					pagination="true" pageSize="20"
					pageList="[10,20,30,40,50,100,150,200]" sortName="companyId"
					rownumbers="true" sortOrder="asc">
					<thead>
						<tr>
							<th field="companyId" width="80" formatter="formatDGField"
								sortable="true" editor="text">公司ID</th>
							<th field="companyName" width="150" formatter="formatDGField"
								sortable="true" editor="text">公司名</th>
							<th field="shopFlag" width="150" formatter="formatterShop"
                                sortable="true" editor="text">门店经营权限</th>
                            <th field="content" width="120" formatter="goDetailedShop"
                                sortable="true">查看所有店面</th>
                            <th field="supFlag" width="150" formatter="formatterSup"
                                sortable="true" editor="text" hidden='true'>供货经营权限</th>
							<th field="content1" width="120" formatter="goDetailedSup" 
							    sortable="true" hidden='true'>查看所有配送中心</th>
						</tr>
					</thead>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>